<!DOCTYPE HTML>
<html>

<head>
<title>Library</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
  <meta name="description" content="website description" />
  <meta name="keywords" content="website keywords, website keywords" />
  <meta http-equiv="content-type" content="text/html; charset=windows-1252" />
  <link rel="stylesheet" type="text/css" href="style/style.css" />
  <style type="text/css">
<!--
.style5 {font-size: 1.5em}
-->
  </style>
</head>

<body>
  <div id="main">
    <div id="header">
      <div id="logo">
        <div id="logo_text">
          <!-- class="logo_colour", allows you to change the colour of the text -->
          <h1 align="center"><strong>Library<span class="logo_colour">System</span></strong></h1>
          <h2 align="center">Department of Science and Technology</h2>
        </div>
      </div>
 <div id="menubar">
        <ul id="menu">      
        <li class="selected"><a href="index.php">List of Books</a></li>
        <li><a href="borrowers.php">List of Borrowers</a></li> 
        <li ><a href="return.php">Return Books</a></li>
        <li><a href="sponsor.php">Sponsorship</a></li>
        <li><a href="login.php">Logout</a></li>
        </ul>
      </div>    </div>
    <div id="content_header">
      
           </div>
    <div id="site_content">
    <form method="post" action="login.php" name="period">
  <input type="submit" value="  Logout  " name="go" />
  </form>     
    <!--  <div id="content"> <li class="selected"><a href="delete1.php">Delete book</a></li>!-->
    <br>
      <p>&rsaquo;&rsaquo;&nbsp;Only the administrator can access this system.<br>
        </p>
        <form id="form2" method="post" action="books.php">
          <table width="870" border="0">
            <tr>
                <td width="160" height="31"><strong>Book category</strong></td>
              <td width="700"><select name="category" id="category">
                <option value="Generalities">Generalities</option>
                <option value="Philosophy and related discipline">Philosophy and related discipline</option>
                <option value="Religion">Religion</option>
                <option value="Social Sciences">Social Sciences</option>
                <option value="Language">Language</option>
                <option value="Pure sciences">Pure sciences</option>
                <option value="Technology">Technology</option>
                <option value="The arts">The arts</option>
                <option value="Literature">Literature</option>
                <option value="Geography and history">Geography and history</option>
              </select></td>
              </tr>
            <tr>
              <td height="22"><strong>Book Title:</strong></td>
              <td><input type="type""text" name="book_name" id="myusername" /></td>
            </tr>
            <tr>
              <td height="24"><strong>Book Author:</strong></td>
              <td><input type="text" name="author" id="myrepeatpassword" /></td>
            </tr>
            <tr>
              <td height="23"><strong>Book Publisher:</strong></td>
              <td><input type="type""text" name="publisher"  id="mylastnamename" /></td>
            </tr>
            <tr>
              <td height="31"><strong>Book Copyright Year:</strong></td>
              <td><input type="text" name="yearPublished" id="textfield3" /></td>
            </tr>
            <tr>
              <td><strong>No. of books:</strong></td>
              <td><input type="text" name="totalCopies" id="textfield4" /></td>
            </tr>
          </table>
          <p>
            <input type="submit" name="submit" value="Add Book"/>
            <input type="reset" name="reset" value="Clear" />
         
            <?php


$submit= isset($_POST['submit']) ? strip_tags($_POST['submit']) : '';

$book_id = isset($_POST['book_id']) ? $_POST['book_id'] : '';
$category = isset($_POST['category']) ? $_POST['category'] : '';
$book_name = isset($_POST['book_name']) ? $_POST['book_name'] : '';
$author = isset($_POST['author']) ? $_POST['author'] : '';

$publisher = isset($_POST['publisher']) ? strip_tags($_POST['publisher']) : '';
$yearPublished = isset($_POST['yearPublished']) ? strip_tags($_POST['yearPublished']) : '';
$totalCopies = isset($_POST['totalCopies']) ? strip_tags($_POST['totalCopies']) : '';


if($submit){
		//open database
		$connect = mysql_connect("localhost","root","") or die("Coudn't connect to database!");
		mysql_select_db("dost");//select database
		
		$check_book_name = mysql_query("SELECT book_name FROM book WHERE book_name='$book_name'");
		$count = mysql_num_rows($check_book_name);
		if($count!=0)
		{
		die ("book is on the bookshelf already");
		}
		


//check for existence
if($book_name&&$author){
	
		//register the user
		echo "Success!";
		$book_name =($book_name);
		echo $book_name;
		
		$queryreg = mysql_query("		
		INSERT INTO book(book_id,book_name,author,publisher,yearPublished,totalCopies,category)
		VALUES('','$book_name','$author','$publisher','$yearPublished','$totalCopies','$category');				
		");
		die("New book has been added in the shelf! ");
		}
	
	
	}
else
	echo "Please fill in the required fields!";





?>
          <p>
        </form>
      </div>
</div>
    <div id="content_footer"></div>
    </div>
</body>
</html>
